﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Web.SessionState;
using Aij1.Utils;

namespace Aij1
{
    /// <summary>
    /// CheckCode 的摘要说明
    /// </summary>
    public class CheckCode : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            string key = CommOp.ToStr(context.Request["CT"]);
            string code = CommOp.ToStr(context.Request["Code"]);
            if (code.Length > 0)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(CheckCodeCreater.IsValid(key, code) ? 1 : 0);
            }
            else
            {
                new CheckCodeCreater(key).Write();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}